#include "select.h"
#include "ui_select.h"
#include <QTimer>

Select::Select(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Select)
{
    ui->setupUi(this);

    setWindowTitle("图表类型选择");
    setWindowIcon(QIcon(":/image/P_mathematics.svg.png"));
    ui->label->setStyleSheet("image: url(:/image/P_mathematics.svg.png);");
    this->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(251,102,102, 200), stop:1 rgba(20,196,188, 210));");
    connect(ui->back,&QPushButton::clicked,[=](){
        emit back();
    });

    createbar = new Bar;
    connect(ui->bar,&QPushButton::clicked,[=](){
        QTimer::singleShot(200,this,[=](){
            this->hide();
            createbar->show();
        });
    });
    connect(createbar,&Bar::back,[=](){
        createbar->close();
        this->show();
    });

    createline =new Line;
    connect(ui->line,&QPushButton::clicked,[=](){
        QTimer::singleShot(200,this,[=](){
            this->hide();
            createline->show();
        });
    });
    connect(createline,&Line::back,[=](){
        createline->close();
        this->show();
    });

    createpie =new Piechart;
    connect(ui->gotopie,&QPushButton::clicked,[=](){
        QTimer::singleShot(200,this,[=](){
            this->hide();
            createpie->show();
        });
    });
    connect(createpie,&Piechart::back,[=](){
        createpie->close();
        this->show();
    });

    createfitting=new Fitting;
    connect(ui->fitting,&QPushButton::clicked,[=](){
        QTimer::singleShot(200,this,[=](){
            this->hide();
            createfitting->show();
        });
    });
    connect(createfitting,&Fitting::back,[=](){
        createfitting->close();
        this->show();
    });

}

Select::~Select()
{
    delete ui;
}
